[jQuery] preload image and show a spinner while loading
Posted
by robertdd
on Stack Overflow
See other posts from Stack Overflow
or by robertdd
Published on 2010-04-18T22:35:40Z
Indexed on
2010/04/18
22:43 UTC
Read the original article
Hit count: 615
Hy,
i use uploadify to upload some images, after i display all the images thumbs in a list, when i click on a image thumb a bigger image it's open in a div with this function
$(".thumbs li a").click(function(){
var largePath = $(this).attr("href");
$('.thumbs li').removeClass('thumbac');
$(this).parent().addClass('thumbac');
$("#largeImg").attr({ src: largePath });
return false;
});
here is my list of photos:
<div class="upimage">
<ul id="upimagesQueue" class="thumbs">
<li id="liupimages">
<a href="uploads/0001.jpg"><img src="uploads/0001.jpg" alt="0001.jpg" id=""></a>
</li>
<li id="liupimages">
<a href="uploads/0002.jpg"><img src="uploads/0002.jpg" alt="0002.jpg" id=""></a>
</li>
<li id="liupimages">
<a href="uploads/0003.jpg"><img src="uploads/0003.jpg" alt="0003.jpg" id=""></a>
</li>
<script>
$(".thumbs li a").click(function(){
var largePath = $(this).attr("href");
$('.thumbs li').removeClass('thumbac');
$(this).parent().addClass('thumbac');
$("#largeImg").attr({ src: largePath });
return false;
});
</script>
</ul>
</div>
this is the div where the images appear
<div class="largeImg" >
<img id="largeImg" src="" />
</div>
how i can preload the image before it display?
© Stack Overflow or respective owner